Split LintExpectationIds#156596
Conversation
It has a single call site.
It's always `None`.
|
The Clippy subtree was changed cc @rust-lang/clippy |
| // -A,-W,-D flags, a `Symbol` for the flag itself and `LevelSpec` for which | ||
| // flag. | ||
| specs: FxIndexMap<LintId, LevelSpec>, | ||
| // -A,-W,-D flags, a `Symbol` for the flag itself and `LevelSpec` for which flag. |
There was a problem hiding this comment.
Is there still a Symbol in here?
There was a problem hiding this comment.
No. LintId wraps Lint which contains a &'static str for the lint name. And the -A,-W,-D part I think is also inaccurate, it's about the lint level which could be specified on the command line but also via an attribute like #[allow(...)].
I think the comment is very out of date and it wasn't that informative anyway. The type itself is fairly straightforward and any alternative comment I could come up with was just something obvious like "a map of lints to lint levels". So I have just removed it.
`LintExpectationId` has two variants, `Unstable` and `Stable`. There are some places where both variants are possible, but there are also places where only one of `Unstable` or `Stable` is possible. This commit encodes this into the type system by introducing new types `UnstableLintExpectationId` and `StableLintExpectationId`. The variants of `LintExpectationId` now enclose these. This makes it clearer what values are possible where. Other things of note: - `LintLevelsProvider` gets an associated type and some method changes. - `LintContext` gets an associated type. - `LevelSpec` is made generic. `UnstableLevelSpec` and `StableLevelSpec` typedefs are added. - The unstable types are now guaranteed by the type system to never be stably hashed. Previously this was a runtime check.
I find these make the code harder to understand.
Describing things that took me a while to work out.
d8bcae9 to
6c9d519
Compare
|
Thanks! r=me once CI pass. |
|
@bors r=GuillaumeGomez |
… r=GuillaumeGomez Split `LintExpectationId`s This PR makes clearer where stable and unstable `LintExpectationIds` can occur, plus a few other small cleanups. Details in individual commits. r? @GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #152852 (Remove driver_lint_caps) - #156121 (compiler: suggest `.collect()` when `String` is expected and `Iterator` is found) - #156518 ([style] rustfmt `match`es with comments in or-patterns) - #156596 (Split `LintExpectationId`s) - #156577 (Test EII UI tests with prefer-dynamic) - #156633 (Add regression test for issue #41261)
… r=GuillaumeGomez Split `LintExpectationId`s This PR makes clearer where stable and unstable `LintExpectationIds` can occur, plus a few other small cleanups. Details in individual commits. r? @GuillaumeGomez
|
@bors try jobs=aarch64-apple |
|
⌛ Trying commit 6c9d519 with merge 1201497… To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/25990802788 |
Split `LintExpectationId`s try-job: aarch64-apple
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: |
… r=GuillaumeGomez Split `LintExpectationId`s This PR makes clearer where stable and unstable `LintExpectationIds` can occur, plus a few other small cleanups. Details in individual commits. r? @GuillaumeGomez
…uwer Rollup of 14 pull requests Successful merges: - #151742 (Remove redundant information in `rustc_abi::Variants`) - #151362 (Add interior-mutability suggestion to `static_mut_refs`) - #156121 (compiler: suggest `.collect()` when `String` is expected and `Iterator` is found) - #156208 (Emit retags in codegen to support BorrowSanitizer (part 1)) - #156596 (Split `LintExpectationId`s) - #156607 (ci: Update FreeBSD version to FreeBSD 14) - #156376 (suggest hex escapes for C-style escapes) - #156577 (Test EII UI tests with prefer-dynamic) - #156585 (explicit tail calls: ignore some tests on unsupported LLVM targets) - #156598 (Avoid rustfix suggestions for macro-expanded unused imports) - #156616 (rustdoc: add test case for `-Drustdoc::` and `--cap-lints`) - #156633 (Add regression test for issue #41261) - #156635 (rename unexpected_try_recover function) - #156636 (minor `rustc_mir_transform` cleanup)
This PR makes clearer where stable and unstable
LintExpectationIdscan occur, plus a few other small cleanups. Details in individual commits.r? @GuillaumeGomez